<template>
  <div id="register_app">
      <!-- http://localhost:3000/api/register -->
      <div>
          <input type="text" placeholder="电话" v-model.trim="form_data.phone">
      </div>    
      <div>
          <input type="text" placeholder="用户名" v-model.trim="form_data.nickname">
      </div>    
      <div>
          <input type="password" placeholder="密码" v-model.trim="form_data.password">
      </div>    
      <div>
          <button type="button" @click="submit">注册</button>
      </div>    
      
  </div>
</template>

<script>
import axios from '../utils/http'



export default {
    data(){
        return {
            form_data: {
                "phone": "",
                "nickname": "",
                "password": ""
            }
        }
    },
    methods: {
        submit(){
            axios(
                "/register", //请求地址
                {
                    method: "POST",
                    data: this.form_data,
                    headers: {
                    }
                }
            ).then(
                res=>{
                    if(res.data.code===200){
                        this.form_data = {
                            "phone": "",
                            "nickname": "",
                            "password": ""
                        }
                        alert("注册成功")
                    }
                }
            ).catch(
                error=>{
                    console.log(error)
                }
            )
        }
    }
}
</script>

<style>

</style>